package com.iplant.wms.service.po.bill;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.iplant.base.po.BasePO;
import com.iplant.base.po.enums.DBSchemas;
import com.iplant.base.utils.annotation.field.DBField;
import com.iplant.base.utils.annotation.condition.DBCondition;
import com.iplant.base.utils.annotation.join.DBJoin;
import com.iplant.base.utils.annotation.join.multi.select.DBJoinMultiSelect;
import com.iplant.base.utils.annotation.po.DBBasePO;
import com.iplant.wms.service.basicenum.bill.WMSOutboundOrderStatus;
import com.iplant.wms.service.basicenum.wms.WMSStockRecordType;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

/**
 * 出库单/入库单
 * 2022-9-24 12:46:56
 * 7401136923cdec15
 */
@DBBasePO(TableName = "wms_outbound_order", Name = false, Active = false,
        CheckName = {"Code"},
        Schemas = DBSchemas.WMS, CodeAuto = true, CodePrefix = "{:TypeCode}-{yyMMdd}-")
public class WMSOutboundOrder extends BasePO implements Serializable {
    private static final long serialVersionUID = 1L;

    @DBCondition
    @DBField(Update = false)
    public int FactoryID = 0;

    @DBJoin(name = "Code", tableName = "fmc_factory", tableAsName = "f1",
            Schemas = DBSchemas.Basic, MainTableField = "FactoryID")
    public String FactoryCode = "";

    @DBJoin(name = "Name", tableName = "fmc_factory", tableAsName = "f1",
            Schemas = DBSchemas.Basic, MainTableField = "FactoryID")
    public String FactoryName = "";

    /**
     * U8采购到货单ID
     */
    @DBCondition
    @DBField
    public int U8_PUArrivalVouchID = 0;
    /**
     * U8采购到货单号
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.like, ParamName2 = "U8_PUArrivalVouchCodeEQ")
    @DBField
    public String U8_PUArrivalVouchCode = "";


    /**
     * U8采购到货单ID
     */
    @DBCondition
    @DBField
    public int U8_PUSalesDeliveryID = 0;
    /**
     * U8采购到货单号
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.like, ParamName2 = "U8_PUSalesDeliveryCodeEQ")
    @DBField
    public String U8_PUSalesDeliveryCode = "";

    /**
     * 发货单ID
     */
    @DBCondition
    @DBField
    public int SalesDeliveryID = 0;
    /**
     * 发货单单号
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.like, ParamName2 = "SalesDeliveryCodeEQ")
    @DBField
    public String SalesDeliveryCode = "";



    /**
     * 关联单据ID
     */
    @DBCondition
    @DBField
    public int TaskDayID = 0;


    /**
     * 收货单ID
     */
    @DBCondition
    @DBField
    public int ReceiveBillID = 0;


    /**
     * 收货单号
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.like, ParamName2 = "ReceiveBillCodeEQ")
    @DBField
    public String ReceiveBillCode = "";


    /**
     * 发货时间  发货后会更改此值
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.geLe, ParamName = "DeliveryTimeStart", ParamName2 = "DeliveryTimeEnd")
    @DBField
    public Calendar DeliveryTime = Calendar.getInstance();

    /**
     * 状态ID
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.in)
    @DBField(CheckValue = true)
    public int Status = 0;
    /**
     * 状态文本
     */
    public String StatusText = "";

    /**
     * 单据类型
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.in)
    @DBField(CheckValue = true)
    public int Type = 0;
    public String TypeText = "";

    public String TypeCode = "";

    /**
     * U8出入库类型代码
     */
    @DBField
    public String U8InOutTypeCode = "";
    /**
     * U8出入库类型名称
     */
    @DBField
    public String U8InOutTypeText = "";

    /**
     * 备注
     */
    @DBField
    public String Remark = "";

    /**
     * 入库、出库明细
     */
    @DBJoinMultiSelect(OutTableField = "OutboundOrderID", ItemClazz = WMSOutboundOrderItem.class)
    public List<WMSOutboundOrderItem> ItemList = new ArrayList<>();


    @DBCondition
    @DBField
    public int StoreID = 0;

    @DBJoin(name = "Name", tableName = "wms_store", tableAsName = "s4",
            JoinMode = DBJoin.DBJoinMode.Left,
            Schemas = DBSchemas.WMS, MainTableField = "StoreID")
    public String StoreName = "";
    @DBJoin(name = "Code", tableName = "wms_store", tableAsName = "s4",
            JoinMode = DBJoin.DBJoinMode.Left,
            Schemas = DBSchemas.WMS, MainTableField = "StoreID")
    public String StoreCode = "";

    public WMSOutboundOrder() {
    }


    @JsonProperty("SalesDeliveryID")
    public int getSalesDeliveryID() {
        return SalesDeliveryID;
    }

    public void setSalesDeliveryID(int salesDeliveryID) {
        this.SalesDeliveryID = salesDeliveryID;
    }

    @JsonProperty("WMSSalesDeliveryCode")
    public String getSalesDeliveryCode() {
        return SalesDeliveryCode;
    }

    public void setSalesDeliveryCode(String salesDeliveryCode) {
        this.SalesDeliveryCode = salesDeliveryCode;
    }


    @JsonProperty("DeliveryTime")
    public Calendar getDeliveryTime() {
        return DeliveryTime;
    }

    public void setDeliveryTime(Calendar deliveryTime) {
        DeliveryTime = deliveryTime;
    }

    @JsonProperty("Status")
    public int getStatus() {
        return Status;
    }

    public void setStatus(int status) {
        Status = status;
    }

    @JsonProperty("StatusText")
    public String getStatusText() {
        StatusText = WMSOutboundOrderStatus.getEnumType(Status).getLabel();
        return StatusText;
    }

    public void setStatusText(String statusText) {
        StatusText = statusText;
    }

    @JsonProperty("ItemList")
    public List<WMSOutboundOrderItem> getItemList() {
        return ItemList;
    }

    public void setItemList(List<WMSOutboundOrderItem> itemList) {
        ItemList = itemList;
    }

    @JsonProperty("Type")
    public int getType() {
        return Type;
    }

    public void setType(int type) {
        Type = type;
        TypeText = WMSStockRecordType.getEnumType(Type).getLabel();
        TypeCode = WMSStockRecordType.getEnumType(Type).getRemark();
    }

    @JsonProperty("Remark")
    public String getRemark() {
        return Remark;
    }

    public void setRemark(String remark) {
        Remark = remark;
    }

    @JsonProperty("TypeText")
    public String getTypeText() {
        TypeText = WMSStockRecordType.getEnumType(Type).getLabel();
        return TypeText;
    }

    public void setTypeText(String typeText) {
        // TypeText = typeText;
    }

    @JsonProperty("TypeCode")
    public String getTypeCode() {
        TypeCode = WMSStockRecordType.getEnumType(Type).getRemark();
        return TypeCode;
    }

    public void setTypeCode(String typeCode) {
        //TypeCode = typeCode;
    }

    @JsonProperty("U8_PUArrivalVouchID")
    public int getU8_PUArrivalVouchID() {
        return U8_PUArrivalVouchID;
    }

    public void setU8_PUArrivalVouchID(int u8_PUArrivalVouchID) {
        U8_PUArrivalVouchID = u8_PUArrivalVouchID;
    }

    @JsonProperty("U8_PUArrivalVouchCode")
    public String getU8_PUArrivalVouchCode() {
        return U8_PUArrivalVouchCode;
    }

    public void setU8_PUArrivalVouchCode(String u8_PUArrivalVouchCode) {
        U8_PUArrivalVouchCode = u8_PUArrivalVouchCode;
    }

    @JsonProperty("U8InOutTypeCode")
    public String getU8InOutTypeCode() {
        return U8InOutTypeCode;
    }

    public void setU8InOutTypeCode(String u8InOutTypeCode) {
        U8InOutTypeCode = u8InOutTypeCode;
    }

    @JsonProperty("U8InOutTypeText")
    public String getU8InOutTypeText() {
        return U8InOutTypeText;
    }

    public void setU8InOutTypeText(String u8InOutTypeText) {
        U8InOutTypeText = u8InOutTypeText;
    }


    @JsonProperty("ReceiveBillID")
    public int getReceiveBillID() {
        return ReceiveBillID;
    }

    public void setReceiveBillID(int receiveBillID) {
        this.ReceiveBillID = receiveBillID;
    }

    @JsonProperty("ReceiveBillCode")
    public String getReceiveBillCode() {
        return ReceiveBillCode;
    }

    public void setReceiveBillCode(String receiveBillCode) {
        this.ReceiveBillCode = receiveBillCode;
    }

    @JsonProperty("StoreID")
    public int getStoreID() {
        return StoreID;
    }

    public void setStoreID(int storeID) {
        StoreID = storeID;
    }

    @JsonProperty("StoreName")
    public String getStoreName() {
        return StoreName;
    }

    public void setStoreName(String storeName) {
        StoreName = storeName;
    }

    @JsonProperty("StoreCode")
    public String getStoreCode() {
        return StoreCode;
    }

    public void setStoreCode(String storeCode) {
        StoreCode = storeCode;
    }

    @JsonProperty("FactoryID")
    public int getFactoryID() {
        return FactoryID;
    }

    public void setFactoryID(int factoryID) {
        FactoryID = factoryID;
    }

    @JsonProperty("FactoryCode")
    public String getFactoryCode() {
        return FactoryCode;
    }

    public void setFactoryCode(String factoryCode) {
        FactoryCode = factoryCode;
    }

    @JsonProperty("FactoryName")
    public String getFactoryName() {
        return FactoryName;
    }

    public void setFactoryName(String factoryName) {
        FactoryName = factoryName;
    }


    @JsonProperty("U8_PUSalesDeliveryID")
    public int getU8_PUSalesDeliveryID() {
        return U8_PUSalesDeliveryID;
    }

    public void setU8_PUSalesDeliveryID(int u8_PUSalesDeliveryID) {
        U8_PUSalesDeliveryID = u8_PUSalesDeliveryID;
    }

    @JsonProperty("U8_PUSalesDeliveryCode")
    public String getU8_PUSalesDeliveryCode() {
        return U8_PUSalesDeliveryCode;
    }

    public void setU8_PUSalesDeliveryCode(String u8_PUSalesDeliveryCode) {
        U8_PUSalesDeliveryCode = u8_PUSalesDeliveryCode;
    }

    @JsonProperty("TaskDayID")
    public int getTaskDayID() {
        return TaskDayID;
    }

    public void setTaskDayID(int taskDayID) {
        TaskDayID = taskDayID;
    }
}
